package com.briansteen.painterface;

import java.awt.BasicStroke;
import java.awt.Color;

import cc.creativecomputing.graphics.CCGraphics;

public class Nerd1Color extends BasicColor {
	private float currRadius = 0;
	private float rand1 = 0;
	private float rand2 = 0;
	public Nerd1Color(float startX, float startY) {
		super(startX, startY);
		brushSize = 15 + (float)Math.random()*5f;
		linesWeight = 3;
		positionTransition = true;
		particleThreshold = 0.12f;
		radiusThreshold = .6f;
		linesAmount = 20;
		dryness = .95f;
		brushSizeX = 1;
		brushSizeY = 1;
		// isWet = true;
		// randomness = true;
		brushPI = 14;
		// gravity = 5f;
		drag = .70f;
		
		transitionX = new float[linesAmount];
		transitionXO = new float[linesAmount];
		transitionY = new float[linesAmount];
		transitionYO = new float[linesAmount];
		alphas = new float[linesAmount];
		for (int i = 0; i < linesAmount; i++) {
			alphas[i] = .2f + (float) Math.random() * .1f;
			transitionX[i] = startX;
			transitionXO[i] = startY;
			transitionY[i] = startX;
			transitionYO[i] = startY;
		}
	}
	
	/**
	 * thickness of brush
	 * @param	speed
	 * @return
	 */
	public float createRadius(float speed) {
		return .95f - (speed*3) / 35;
	}
	
	/**
	 * draws into sprite
	 */
	public void drawBrush(int ID, CCGraphics g2d, float radius, float lineXO, float lineX, float lineYO, float lineY, float alpha) {
		float speedX = lineX - lineXO;	
		float speedY = lineY - lineYO;
		// float speed = (float)Math.sqrt(speedX*speedX + speedY*speedY);
		if(alpha > 1) alpha = 1;
		
		Color theColor = new Color(red, green, blue, alpha);
		BasicStroke basicStroke = new BasicStroke(linesWeight * radius,BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
		g2d.color(red, green, blue, alpha*2);
		g2d.strokeWeight(linesWeight * radius);
		g2d.line((int) lineXO, (int) lineYO, (int) lineX, (int) lineY);
		
		/*
		if(Math.random() < .001f) {
			int splatterAmount = (int)Math.floor(Math.random()*10);
			Color splatterColor = new Color(red, green, blue);
			g2d.color(red, green, blue);
			for(int i=0;i<splatterAmount;i++) {
				float splatterRadius = (float)Math.random()*30;
				float splatterDegree = (float)Math.random()*((float)Math.PI*2);
				float splatterSize = 2 + (float)Math.random()*5;
				float spX = lineX + (float)Math.cos(splatterDegree)*splatterRadius;
				float spY = lineY + (float)Math.sin(splatterDegree)*splatterRadius;
								
				BasicStroke splatterBasicStroke = new BasicStroke(splatterSize,BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
				g2d.color(red, green, blue, alpha);
				g2d.strokeWeight(splatterSize);
				g2d.line((int)spX, (int)spY,(int)spX + 1, (int)spY);				
			}
		}
		*/
	}		
}